"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccountModel = void 0;
const ErrorCode_1 = require("../../src/config/ErrorCode");
const GameConfig_1 = require("../../src/config/GameConfig");
const ServerConfig_1 = require("../../src/config/ServerConfig");
const ResponseModel_1 = require("../../src/model/ResponseModel");
const AccountDao_1 = require("../dao/AccountDao");
const Time_Check_Inteval = 1000 * 60 * 60;
const Time_Delete_Inteval = 1000 * 60 * 60 * 24;
class AccountModel {
    static login_async(account, sign) {
        return __awaiter(this, void 0, void 0, function* () {
            let respModel = new ResponseModel_1.ResponseModel();
            let accountResult = yield AccountDao_1.AccountDao.get_account_info(account);
            if (accountResult) {
                if (ServerConfig_1.ServerConfig.nowServerConfig.status == ServerConfig_1.ServerConfig.Status_Type.Weihu) {
                    if (accountResult.status != GameConfig_1.GameConfig.Status_Type.Test) {
                        respModel.code = ErrorCode_1.ErrorCode.Code.Fail;
                        respModel.msg = "服务器维护";
                    }
                }
                if (sign == accountResult.token) {
                    respModel.code = ErrorCode_1.ErrorCode.Code.Suc;
                    respModel.msg = "";
                }
                else {
                    respModel.code = ErrorCode_1.ErrorCode.Code.LoginError_token;
                    respModel.msg = "token错误,请重新登录";
                }
            }
            else {
                respModel.code = ErrorCode_1.ErrorCode.Code.LoginError_NoUser;
                respModel.msg = "账号不存在";
            }
            return respModel;
        });
    }
}
exports.AccountModel = AccountModel;
